package com.richard.springcloud.config;

import org.springframework.cloud.gateway.route.RouteLocator;
import org.springframework.cloud.gateway.route.builder.RouteLocatorBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class GatewayConfig {
	//https://spring.io/projects/spring-cloud-gateway
	@Bean
	public RouteLocator customRouteLocator(RouteLocatorBuilder builder) {
		//代理转发 ${gateway.context}/guonei -> http://news.baidu.com/guonei
		return builder.routes()
				.route("path_route_guonei", r -> r.path("/guonei")
					.uri("http://news.baidu.com/guonei"))
				.route("path_route_guoji", r -> r.path("/guoji")
					.uri("http://news.baidu.com/guoji"))
				.build();
	}
}
